package logic;

import java.io.FileOutputStream;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;

//		This class writes our Receipt pdf file for later sending
public class WriteFile {

	public WriteFile(String email, String dateTimeTxt, String dateTime,
			String amount, String copy) {

		Rectangle pageSize = new Rectangle(500, 400);
		pageSize.setBackgroundColor(new BaseColor(255, 0, 188));
		Document document = new Document(pageSize);
		try {
			PdfWriter writer = PdfWriter.getInstance(document,
					new FileOutputStream("Receipt" + email + ".pdf"));
			document.open();
			PdfContentByte settings = writer.getDirectContent();
			BaseFont f = BaseFont.createFont(BaseFont.HELVETICA,
					BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
			document.open();
			settings.setFontAndSize(f, 2);
			document.addTitle("Your Receipt");
			document.add(new Paragraph(
					"                  "
							+ dateTimeTxt
							+ "\n\n           "
							+ dateTime
							+ "\n\n                                           Transfered Amount: "
							+ amount + "\n\n" + copy));
			document.addCreator("\n\n\n Nice doin' business with you,\t BCBS Systems\n");
			document.close();

		} catch (Exception e) {
			e.printStackTrace();

		}
	}
}
